package com.tangula.web.kashine.controller;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.tangula.controller.ReturnRespController;
import com.tangula.core.Context;
import com.tangula.core.Controller;
import com.tangula.web.config.auth.Ignore;
import com.tangula.web.form.DefaultPagingBody;
import com.tangula.web.kashine.business.StudentAwardBusiness;
import com.tangula.web.kashine.business.StudentBusiness;
import com.tangula.web.kashine.entity.AccountEntity;
import com.tangula.web.kashine.entity.AwardForm;
import com.tangula.web.kashine.entity.BaseRespEntity;
import com.tangula.web.kashine.entity.ClassEntity;
import com.tangula.web.kashine.entity.HistoryForm;
import com.tangula.web.kashine.entity.SendForm;
import com.tangula.web.kashine.entity.SendMoneyFoem;
import com.tangula.web.kashine.entity.StudentOrgRefForm;
import com.tangula.web.kashine.entity.StudentPageableForm;
import com.tangula.web.kashine.entity.StudentSendMoneyForm;

@RestController
@RequestMapping("/studentController")
@ResponseBody
public class StudentController  implements Controller<Context>, ReturnRespController,AuthController{
	@Autowired
	StudentBusiness studentBusiness;
	@Autowired
	StudentAwardBusiness studentAwardBusiness;
	/**
	 * 学生注册
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/postRegister",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<Boolean>> postRegister(@RequestBody AccountEntity account){
		return returnSuccess(studentBusiness.register(account)!=null);
	}
	/**
	 * 学生查看奖励
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/loadStudentAwards",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<AwardForm>>> putShowAward(@RequestBody StudentPageableForm student){
		student.setCondition(this.loadCurrentAccount().getId());
		return returnSuccess(studentAwardBusiness.showAwaed(student));
	}
	/**
	 * 学生给教师发送基金
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/sendMoney2Teacher",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<Boolean>> postMonryToTeacher(@RequestBody SendForm send){
		return returnSuccess(studentBusiness.sendMoneyToTeacher(send,loadCurrentAccount()));
	}
	/**
	 * 学生查看基金
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/putShowMoney",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<StudentOrgRefForm>>> putShowMoney(@RequestBody StudentPageableForm student){
		return returnSuccess(studentBusiness.showMoney(student));
	}
	/**
	 * 学生查看历史记录
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/putShowHistory",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<HistoryForm>>> putShowHistory(@RequestBody StudentPageableForm student){
		return returnSuccess(studentBusiness.showHistory(student));
	}
	/**
	 * 学生查看所属班级
	 * @param user .
	 * @return .
	 */
	@RequestMapping(value = "/loadClassOfStudent",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<ClassEntity>>> putShowClass(@RequestBody StudentPageableForm student){
		return returnSuccess(studentBusiness.showClass(student));
	}
	/**
	 * 学生查看消费记录
	 * @param user .
	 * @return .
	 * @throws Exception 
	 */
	@RequestMapping(value = "/loadStudentSendMoneyHistory",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<SendMoneyFoem>>> loadStudentSendMoneyHistory(@RequestBody StudentSendMoneyForm student){
		return returnSuccess(studentBusiness.loadStudentSendMoneyHistory(student));
	}
	/**
	 * 查询当前用户的所有教师
	 * @param user .
	 * @return .
	 * @throws Exception 
	 */
	@RequestMapping(value = "/loadAllTeachersOfStudent",consumes = "application/json",method = {RequestMethod.POST })
	@Ignore
	public ResponseEntity<BaseRespEntity<DefaultPagingBody<AccountEntity>>> loadAllTeachersOfStudent(@RequestBody StudentPageableForm student) {
		return returnSuccess(studentBusiness.loadAllTeachersOfStudent(student));
	}
}
